METHOD:  Document::open


document.open([mimeType[, replace]])

This method is used to open a stream to collect the output from any write or writeln methods. The first of the optional parameters is mimeType which determines the type of document you are writing to; if this parameter is not used, the default value is "text/html". The second parameter is replace, also optional, which causes the history entry for the new document to inherit the history entry from the document from which it was opened.

The following code demonstrates this method and displays the output stream in a new window.

Code:
function newWindowTest() {
  var message1 = "Hello, world!"
  var message2 = "This is a test."
  newWindow.document.open("text/html", "replace")
  newWindow.document.writeln("message1)
  newWindow.document.write("message2)
  newWindow.document.close()
}

newWindow=window.open('','','toolbar=no,scrollbars=no,width=200,height=150')
newWindowTest()

Output: (to new window)
"Hello, world! This is a test."


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information